package com.qf.juc.demo.violetdemo;

import java.util.concurrent.atomic.AtomicInteger;

public class VioletDemo1 {

    private volatile static AtomicInteger num = new AtomicInteger();
//    private volatile static int num = 0;


    public static void add(){
        num.getAndIncrement();
    }

    public static void main(String[] args) {

        for (int i = 0; i < 150; i++) {
            new Thread(()->{
//                for (int j = 0; j < 1000; j++) {
                    add();
//                }
            }).start();
        }
        while (Thread.activeCount()>2){
                Thread.yield();
        }
        System.err.println("num:"+num);
    }
}
